import './assets/main.css'

import {
	createApp
} from 'vue'
import App from './App.vue'

// 导入ElementPlus
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
// ElementPlus国际化
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
// 导入ElementPlus图标
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
// 导入路由
import {
	createRouter,
	createWebHashHistory
} from 'vue-router'
// 导入pinia
import {
	createPinia
} from 'pinia'
// 导入pinia持久化插件
import piniaPluginPersist from 'pinia-plugin-persist'

// 导入自定义组件
import Home from './components/Home.vue';
import HospitalSet from './components/HospitalSet.vue';
import Hospital from './components/Hospital.vue';

// 创建pinia实例
const pinia = createPinia()
// 注册pinia持久化插件
pinia.use(piniaPluginPersist)

//定义路由
const routes = [{
	path: '/',
	component: Home,
	children: [
		{ path: '/hospitalSet', component: HospitalSet },
		{ path: '/hospital', component: Hospital },
	]
}, ]

//创建路由实例
const router = createRouter({
	history: createWebHashHistory(), //hash模式
	routes
})

const app = createApp(App)
app.use(pinia) // 全局注册pinia
	// 全局注册ElementPlus并设置中文
	.use(ElementPlus, {
		locale: zhCn
	})

//注册ElementPlus所有图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
	app.component(key, component)
}
app.use(router) //全局注册路由
app.mount('#app')